home *** CD-ROM | disk | FTP | other *** search
-
-
- {$R-} { turn off range checking (if on) }
- {$V-} { turn off string parm length checking }
-
- {
- procedures and functions in this library
-
- LowToUp converts string to uppercase
- Strip removes any leading characters
- Parse gets next word out of string
- Replace replaces all instance of one substring with another
-
- }
-
- type
- BigStr = string[255];
- SetOfChar = set of Char;
-
- procedure LowToUp(var TStr : BigStr);
- {
- purpose converts TStr to all upper case
- last update 23 Jun 85
- }
- var
- Len,Indx : Integer;
- begin
- Len := Length(TStr);
- for Indx := 1 to Len do
- TStr[Indx] := UpCase(TStr[Indx])
- end; { of proc LowToUp }
-
- procedure Strip(var Line : BigStr; var Len : Integer; Break : SetOfChar);
- {
- purpose pull out all chars in Break from start of Line
- last update 09 Jul 85
- }
- var
- Indx : Integer;
- begin
- Len := Length(Line);
- if Len > 0 then begin
- Indx := 0;
- while (Line[Indx+1] in Break) and (Indx < Len) do
- Indx := Indx + 1;
- Delete(Line,1,Indx);
- Len := Len - Indx;
- end
- end; { of proc Strip }
-
- procedure Parse(var Line,Word : BigStr; Break : SetOfChar);
- {
- purpose removes first word in Line and returns it in Word
- last update 23 Jun 85
- }
- var
- Len,Indx : Integer;
- begin
- Word := '';
- Strip(Line,Len,Break);
- if Len = 0
- then Exit;
- Indx := 0;
- while not (Line[Indx+1] in Break) and (Indx < Len) do
- Indx := Indx + 1;
- Word := Copy(Line,1,Indx);
- Delete(Line,1,Indx);
- Strip(Line,Len,Break)
- end; { of proc Parse }
-
- procedure Replace(var Target : BigStr; OldStr,NewStr : BigStr; MaxLen : Byte);
- {
- purpose look for all instances of OldStr and replace with NewStr
- last update 09 Jul 85
- }
- var
- TarLen,OldLen,IncLen,Indx
- : Integer;
- begin
- TarLen := Length(Target);
- OldLen := Length(OldStr);
- IncLen := Length(NewStr) - OldLen;
- Indx := Pos(OldStr,Target);
- while Indx > 0 do begin
- if TarLen + IncLen <= MaxLen then begin
- Delete(Target,Indx,OldLen);
- Insert(NewStr,Target,Indx);
- TarLen := TarLen + IncLen;
- Indx := Pos(OldStr,Target)
- end
- else Indx := 0
- end
- end; { of proc Replace }
-
-